{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "readfile = 'C:/Users/ZZK/Documents/auto_drive/train_dataset/train.txt' \n",
    "writefile = 'C:/Users/ZZK/auto_drive/data/dataset/auto_drive_train2000.txt'\n",
    "file_to_write = open(writefile, 'w')\n",
    "i = 0\n",
    "with open(readfile, 'r') as file_to_read:\n",
    "    while True:\n",
    "        lines = file_to_read.readline() # 整行读取数据\n",
    "        if not lines:\n",
    "            break\n",
    "        i += 1\n",
    "        if i == 2000:\n",
    "            break\n",
    "        line_len = len(lines.split( ))\n",
    "        for i in range(line_len):\n",
    "            if i == 0:\n",
    "                file_to_write.write('C:/Users/ZZK/Documents/auto_drive/train_dataset/train_image/' + lines.split( )[i] + ' ')   \n",
    "            elif i == 1:\n",
    "                continue\n",
    "            else:\n",
    "                file_to_write.write(lines.split( )[i][:-2] + ' ')\n",
    "        file_to_write.write('\\n')\n",
    "file_to_write.close()\n",
    "file_to_read.close()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
